package tblModelDrank;

import java.util.ArrayList;

import javax.swing.event.TableModelListener;
import javax.swing.table.TableModel;
import daoDataFactory.DaoFactory;
import domijn.Drank;
import pnlBeheer.PnlGDBeheer;

public class TMDrank implements TableModel {

	@SuppressWarnings("unused")
	private PnlGDBeheer pnlGDBeheer;
	private String []names = {"Menu","Categorie","Nummer","Naam","Prijs", "Omschrijving"};
	private ArrayList<Drank> aldranken;
	private Drank d;
	
	public TMDrank(PnlGDBeheer pnlGDBeheer) {
		this.pnlGDBeheer = pnlGDBeheer;
		aldranken = DaoFactory.getwokapplicatie().getDaoIDrank().loadall();
	}
	@Override
	public int getRowCount() {
		return aldranken.size();
	}

	@Override
	public int getColumnCount() {
		return names.length;
	}
	
	@Override
	public String getColumnName(int column) {
		return names[column];
	}

	@Override
	public Class<Drank> getColumnClass(int column) {
		return Drank.class;
	}

	@Override
	public boolean isCellEditable(int arg0, int arg1) {
		return false;
	}
	
	@Override
	public Object getValueAt(int rowIndex, int columnIndex) {
		d = aldranken.get(rowIndex);
		 switch (columnIndex){
         case 0:
        	 return d.getMenu();
         case 1: 
        	 return d.getCat();
         case 2:
             return d.getDrNewNumber();
         case 3:
        	 return d.getDrName();
         case 4:
        	 return d.getDrPrice();
         case 5:
        	 return d.getDrDiscr();
            }
        return d;
        }
	
	@Override
	public void setValueAt(Object arg0, int arg1, int arg2) {
	}
	
	@Override
	public void addTableModelListener(TableModelListener arg0) {
	}
	
	@Override
	public void removeTableModelListener(TableModelListener arg0) {
	}
    public void addDrank(final Drank drank) {
        aldranken.add(drank);
    }
}
